from urllib.parse import parse_qs

payload = 'AppntNo=142223952&contPlancode=123&contPlancodeGridverify=1&contPlancodeGridverify=3'
def debug_decorator(func):
    def wrapper(*args, **kwargs):
        # 打印函数调用前的调试信息
        print(f"Calling function {func.__name__} with args: {args} and kwargs: {kwargs}")
        # 调用原始函数
        result = func(*args, **kwargs)
        # 打印函数调用后的调试信息
        print(f"Function {func.__name__} returned: {result}")
        return result

    return wrapper


@debug_decorator
def add_numbers(a, b):
    return a + b


# 测试装饰器
result = add_numbers(3, 5)

import functools


def my_decorator(func):
    # @functools.wraps(func)
    def wrapper(*args, **kwargs):
        print("Before function call")
        result = func(*args, **kwargs)
        print("After function call")
        return result

    return wrapper


@my_decorator
def example():
    """This is an example function."""
    print("Inside the example function")


print(example.__name__)
print(example.__doc__)

# 解析 payload 字符串
parsed_payload = parse_qs(payload)
print("parsed_payload", parsed_payload)

# 处理值列表，若列表只有一个元素则取该元素
result = {key: value[0] if len(value) == 1 else value for key, value in parsed_payload.items()}

print(result)